<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<title>${name_china}管理列表</title>
<%@include file="/common/head.jsp" %>

<!-- 时间日期插件 -->
<link href="<%=request.getContextPath()%>/static/plugin/My97DatePicker/skin/default/datepicker.css" rel="stylesheet" >
<script src="<%=request.getContextPath()%>/static/plugin/My97DatePicker/WdatePicker.js"></script>
<style type="text/css">
#table td,#table th{
	border:1px solid #ccc;
	padding:1% 1%;
	text-align:center

}
</style>
</head>
<body class="iframe-page">
<div class="page-title-wrapper">
    <div class="page-title">
        <div class="page-title-text">
            <span>成员列表</span>
            <a id="goBack" class="btn-return distance-left" href="javascript:;"><i class="icon icon-arrow-left"></i>返回上级</a>
        </div>
        <div id="toolbar"  style="float: right">
	          
        </div>
    </div>
    <div class="page-title-border"></div>
</div>
<hr/>
<br/>
<div>
	<table class="table" id="table">

		<tr>
			<th>时间</th>
			<th>订单数</th>
			<th>有效订单</th>
			<th>金额</th>
			<th>累计总额</th>
			<th>建群数</th>
		</tr>
		<tr>
			<td>今日</td>
			<td>3000000</td>
			<td>2000000</td>
			<td>100000.00</td>
			<td>100</td>
			<td>100</td>
		</tr>
		<tr>
			<td>本周</td>
			<td>3000000</td>
			<td>2000000</td>
			<td>100000.00</td>
			<td>100</td>
			<td>100</td>
		</tr>
		<tr>
			<td>本月</td>
			<td>3000000</td>
			<td>2000000</td>
			<td>100000.00</td>
			<td>100</td>
			<td>100</td>
		</tr>
		<tr>
			<td>本季度</td>
			<td>3000000</td>
			<td>2000000</td>
			<td>100000.00</td>
			<td>100</td>
			<td>100</td>
		</tr>
		<tr>
			<td>本年</td>
			<td>3000000</td>
			<td>2000000</td>
			<td>100000.00</td>
			<td>100</td>
			<td>100</td>
		</tr>
	</table>
</div>


<div class="search-field">
    <span class="field-cont">
        <span class="field-cont-title">成员名称:</span>
         <input type="text" class="summer-input" id="userName"/>
    </span>
   <span class="field-cont">
        <span class="field-cont-title">手机号:</span>
         <input type="text" class="summer-input" id="userPhone"/>
   </span>
    
    <span class="field-cont">
        <span class="field-cont-title">订单数:</span>
         <input type="text" class="summer-input" id="orderCount"/>
    </span>
    <span class="field-cont">
        <span class="field-cont-title">总额:</span>
         <input type="text" class="summer-input" id="totalMoney"/>
    </span>
     <span class="field-cont">
        <span class="field-cont-title">群数:</span>
         <input type="text" class="summer-input" id="groupCount"/>
    </span>
    <span class="field-btn-wrapper">
        <a id="search" class="btn btn-primary btn-icon wave distance-right"><i class="icon icon-search"></i></a>
        <a id="reset" class="btn btn-icon wave wave-dark"><i class="icon icon-refresh"></i></a>
    </span>
    
</div>

<div id="t-wrap">
    <table class="summer-datagrid" id="dataList">
	    <col width="20%">
	    <col width="20%">
	    <col width="20%">
	    <col width="20%">
	    <col width="20%">
	    <col width="20%">
	    <col width="20%">
	    <thead>
		    <tr>
		        <th>成员名称</th>
				<th>手机号</th>
		        <th>推广位数</th>
		        <th>累计订单</th>
		        <th>累计总额</th>
		        <th>累计建群</th>
		        <th>操作</th>
		    </tr>
	    </thead>
    </table>
</div>

<script>
	//请求url
	var CONST_URL = {
		INIT:basePath + '${common_url}init',
		LIST: basePath + '${common_url}list',
	   	INIT_USER_ADD: basePath + "${common_url}initUserAdd",
	   	INIT_EDIT: basePath + "${common_url}initEdit",
	   	DEL: basePath + "${common_url}del",
	   	INIT_VIEW: basePath + "${common_url}initView",
	   	INIT_PERFORM_LIST :basePath + "${common_url}initPerformList",
	   	INIT_PERFORM_DEL :basePath + "${common_url}user/del",
		EDIT_USER_VIEW :basePath + "${common_url}editUserView",
		SET_TGW_VIEW :basePath + "${common_url}setTGWView",
	   	
	};
	
    var  permission = CommonUtil.getPermission('${name_english}');
    
    $(function () {
        // 新建toobar
		$.funcbar({
			id: 'toolbar',
			type: 'toolbar',
			data: permission,
			permit: ['${name_english}:addUserView'],
		});
	
        
        // 查询按钮
        $('#search').on('click', reloadTable);
        
        //重置按钮
        $('#reset').on('click', function () {
        	//重置文本框的值
        	$('#${name_english}Version').val('');
        	$('#startTime').val(''); 
        	$('#stopTime').val('');
        	reloadTable();
        });
        
        //新建
        $('#toolbar').on('click', 'a[data-permit="${name_english}:addUserView"]', function() {
        	window.location.href = CONST_URL.INIT_USER_ADD+"?groupId=${groupId}"; 	  	
		});
        
        
       createTable();
        
        //查看
        $('#t-wrap').on('click', 'a[data-permit="${name_english}:initView"]', function() {
        	var $this = $(this),
        	    id = $this.closest('tr').find('td[data-field="id"]').attr('data-value');
        	window.location.href = CONST_URL.INIT_VIEW +"?id=" + id;
        });
       
        //编辑
        $('#t-wrap').on('click', 'a[data-permit="${name_english}:editUserView"]', function() {
            var $this = $(this),
                id = $this.closest('tr').find('td[data-field="id"]').attr('data-value');
            window.location.href = CONST_URL.EDIT_USER_VIEW + '?id=' + id+'&groupId=${groupId}';
        });	
        
        $('#t-wrap').on('click', 'a[data-permit="${name_english}:setTGWView"]', function() {
            var $this = $(this),
                id = $this.closest('tr').find('td[data-field="id"]').attr('data-value');
            window.location.href = CONST_URL.SET_TGW_VIEW + '?userId=' + id+'&groupId=${groupId}';
        });	
        
        //删除
		$('#t-wrap').on('click', 'a[data-permit="${name_english}:deleteUser"]', function() {
			var $this = $(this),
			    id = $this.closest('tr').find('td[data-field="id"]').attr('data-value');
			$.sdialog({
				type: 'confirm',
				msg: '您确定要删除选中的记录吗?',
				onConfirm: function(result) {
				    if (result) {
				    	$.sajax({
			                url : CONST_URL.INIT_PERFORM_DEL + "?id=" + id,
			                onLoadSuccess : function() {
			                	 $.stip({
                	                type:'ok',//显示类型 有info、 ok、 danger
                	                text: '删除成功！'    
			                	});
			                	reloadTable();  
			                }
			            });
				    		
				    }	
				}
			});
		});
    });
    
    // 重新加载表格
	function reloadTable() {
		$('#dataList').datagrid('reload',{
            ajax: {
            	param: {
            		"userName": trimSpace($('#userName').val()),
                	"userPhone": trimSpace($('#userPhone').val()),
                	"orderCount": trimSpace($('#orderCount').val()),
                	"money": trimSpace($('#totalMoney').val()),
                	"groupCount": trimSpace($('#groupCount').val())
            	}
            }
        });
	}
    
    //创建表格
    function createTable() {
    	$('#dataList').datagrid({
    		ajax: {
    			url: CONST_URL.INIT_PERFORM_LIST,
    			param: {
    				"id": trimSpace(${groupId})
                	/* "startTime": trimSpace($('#startTime').val()),
                	"stopTime": trimSpace($('#stopTime').val()) */
            	} 
    		},
    		columns: [
    		     {
    		    	 field: 'id',
    		    	 hidden: true
    		     },
    		     {
    		    	 field: 'name',
    		    	
    		     },
    		     {
    		    	 field: 'phone'
    		     },{
    		    	 field: 'tgwCount'
    		     },{
    		    	 field: 'orderCount'
    		     },{
    		    	 field: 'totalMoney'
    		     },{
    		    	 field: 'groupCount'
    		     },
    		     {
    		    	 render: function (rowData) {
    		    		 return $.funcbar({
    		    			 data: permission,    //请求的数据
    		    			 type: 'text',     //类型
    		    			 display: 2,    //显示数量
    		    			 permit: ['${name_english}:setTGWView','${name_english}:editUserView','${name_english}:deleteUser'] //需要的权限按钮
    		    		 });
    		    	 }
    		    }
    		    
    		          
    	    ]
    	});
    }
    $('#backBtn,#goBack').on('click',backMain);
    function backMain() {
    	window.location.href = CONST_URL.INIT;
    }
</script>
</body>
</html>